package com.xiaozou.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Configuration
public class Knife4jConfig {

    @Bean
    public Docket createInternalDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .ignoredParameterTypes(HttpSession.class, HttpServletRequest.class)
                .enable(true)
                .apiInfo(new ApiInfoBuilder().title("智能问答平台").version("1.0.0").build())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tanyuai.chatbot.qa.http.internal"))
                .paths(PathSelectors.any())
                .build()
                .groupName("内部接口");
    }

    @Bean
    public Docket createOuterDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .ignoredParameterTypes(HttpSession.class, HttpServletRequest.class)
                .enable(true)
                .apiInfo(new ApiInfoBuilder().title("智能问答平台").version("1.0.0").build())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tanyuai.chatbot.qa.http.outer"))
                .paths(PathSelectors.any())
                .build()
                .groupName("B端接口");
    }

    @Bean
    public Docket createOpenDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .ignoredParameterTypes(HttpSession.class, HttpServletRequest.class)
                .enable(true)
                .apiInfo(new ApiInfoBuilder().title("智能问答平台").version("1.0.0").build())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tanyuai.chatbot.qa.http.open"))
                .paths(PathSelectors.any())
                .build()
                .groupName("开放接口");
    }
}
